package com.yaj.myfactorysupport.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author wei
 * @since 2021-04-20
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("TM_WORKER")
public class TmWorker implements Serializable, UserDetails {

    private static final long serialVersionUID = 1L;

    /**
     * ???ID
     */
    @TableId(value = "WORKER_ID", type = IdType.NONE)
    private String workerId;

    /**
     * ????
     */
    @TableField("WORKER_NAME")
    private String workerName;

    /**
     * ???????ID
     */
    @TableField("WORKER_GRP_ID")
    private String workerGrpId;

    /**
     * ??????
     */
    @TableField("WORKER_TYPE")
    private String workerType;

    /**
     * ICID
     */
    @TableField("IC_ID")
    private String icId;

    /**
     * ?????
     */
    @TableField("ACTIVE_FLAG")
    @TableLogic
    private String activeFlag;

    /**
     * ???ID
     */
    @TableField("CREATED_BY")
    private String createdBy;

    /**
     * ????
     */
    @TableField("CREATE_TIMESTAMP")
    private Date createTimestamp;

    /**
     * ???ID
     */
    @TableField("UPDATED_BY")
    private String updatedBy;

    /**
     * ????
     */
    @TableField("UPDATE_TIMESTAMP")
    private Date updateTimestamp;


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return null;
    }

    @Override
    public String getUsername() {
        return workerId;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return activeFlag.equals("1");
    }
}
